<!--
 * @Author: 菅书繎 2032642089@qq.com
 * @Date: 2025-09-11 08:40:45
 * @LastEditors: 菅书繎 2032642089@qq.com
 * @LastEditTime: 2025-09-17 16:45:46
 * @FilePath: \大三上 前端\city\src\pages\components\Bottom1.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div>
        <Title :title="title"></Title>
        <div ref="bottom1" style="height: 150px;margin-top:10px"></div>
    </div>
</template>
<script>
import { Chord } from '@antv/g2plot';
import { get } from '@/utils/request';
import moment from 'moment';
import { mapState } from 'vuex';
export default {
    data() {
        return {
            title: '监控月报',
            oneData: [],
            chord:null,
           params:{}


        }

    },
    computed: {
        ...mapState(['ed'])
    },
    //侦听器 侦听数据
    watch: {
        ed: {
            handler(n, o) {
                //根据设备信息重新查询数据，重新渲染图表
                this.params.engineer_id = n.engineer_id;
                this.params.device_id = n.device_id;
                this.getEmpData();
                //根据最新获取的数据重新渲染图表
                this.chord.changeData(this.oneData);
            },

            //深度监听
            deep: true
        }
    },
    methods: {
        deOnePhoto() {
            
            this.chord = new Chord(this.$refs.bottom1, {

                data: this.oneData,
                sourceField: 'type',
                targetField: 'insert_time',
                weightField: 'value',
            });

           this.chord.render();

        },
        async getEmpData() {
            let res = await get('/dashboard/queryMouthData');
            console.log(res, '11');
            res.data.forEach((item, index, arr) => {
                item.insert_time = moment(item.insert_time).format("HH:mm");
            });
            this.oneData = res.data;
        }


    },
    async mounted() {
        await this.getEmpData();
        this.deOnePhoto();

    }


}
</script>
<style lang="less" scoped></style>